<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Example</title>
</head>

<body>
  <p id="msg"></p>
  <button type="button" name="button" id="banana">Banana</button>
  <button type="button" name="button" id="apple">Apple</button>

  <script type="text/javascript">
    var sel = "No selection made";
    document.getElementById('msg').innerHTML = sel;
    var buttons = document.getElementsByTagName('button');
    for (var i = 0; i < buttons.length; i++) {
      buttons[i].onclick = function(e) {
        document.getElementById('msg').innerHTML = e.target.innerHTML;
      };
    }
  </script>
</body>

</html>
